﻿using Hopscotch.Presentation.Common;
using Hopscotch.Presentation.Common.Utils;
using Hopscotch.Presentation.Controls.Core;
using Hopscotch.Presentation.PartyModule.Constants;
using System;

namespace Hopscotch.Presentation.PartyModule.ViewModels
{
    public class AccountViewModel : ViewModelBase
    {    
        public AccountViewModel()			
        {
            this.ViewTitle = "Account";
            Icon16Uri = new Uri(IconPaths.Book16);
        }

        //zxzx,
        private decimal qtyTest;
        public decimal QtyTest
        {
            get { return qtyTest; }
            set
            {
                if (qtyTest == value)
                    return;

                qtyTest = value;
                
                Validate();
                RaisePropertyChanged("QtyTest");
            }
        }

        private decimal priceTest;
        public decimal PriceTest
        {
            get { return priceTest; }
            set
            {
                if (priceTest == value)
                    return;

                priceTest = value;
                
                Validate();
                RaisePropertyChanged("PriceTest");
            }
        }

    
        public override void OnValidate()
        { 
            if (PriceTest < 0)
            {
                this.AddError("PriceTest", "Price can't be negative");
            }
            else if (PriceTest < 1000)
            {
                this.AddInfo("PriceTest", "Price is less than 1k");
            }
            else if (PriceTest > 1000)
            {
                this.AddWarning("PriceTest", "Price is greater than 1k");
            }
        }

    }
}
